<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>员工培训查询</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">
		<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<%include("/common/include.html"){}%>
		<style type="text/css">
		.textbox {
			padding-right: 0px;
			background: url("${cxt !}/sb/themes/insdep/images/combo_arrow.png")
				no-repeat scroll right center transparent;
		}
		</style>
	</head>
	
	<body class="easyui-layout">
			<div data-options="region:'north',split: true,title:'快速查询'" style="height:200px;padding:10px;">
				<form id="toShopStatisticFrom" action="${cxt!}/toShopStatistic/excel">
				   <div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">开始时间</label>
						<input name="_query.startTime" id="startTime" value='${startTime !}' class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center" 
							data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">结束时间</label>
						<input name="_query.endTime" id="endTime" value='${date(),dateFormat="yyyy-MM-dd"}' class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center" 
							data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">查询门店</label>
						<input id="organ" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="showMenu(); return false;" class="textbox" value="${organization.name}"/>
						<input name="_query.organIds" id="organIds" type="hidden" value="${organization.ids}">
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">转入门店</label>
						<input id="intoorgan" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="intoshowMenu(); return false;" class="textbox" />
						<input name="_query.intoOrganIds" id="intoorganIds" type="hidden">
						<input  id="parentOrganIds" type="hidden" value="${parentOrgan.ids !}">
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">转出门店</label>
						<input id="outorgan" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="outshowMenu(); return false;" class="textbox" />
						<input name="_query.outOrganIds" id="outorganIds" type="hidden" >
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">顾客编号</label>
						<input  id="cushybh" name="_query.cushybh" class=" easyui-textbox theme-textbox-radius" style="width:212px;height:32px;text-align:center"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">顾客姓名</label>
						<input  name="_query.cusname" id="cusname" class=" easyui-textbox theme-textbox-radius" style="width:212px;height:32px;text-align:center"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">顾客手机号</label>
						<input  name="_query.cusphone" id="cusphone" class=" easyui-textbox theme-textbox-radius" style="width:212px;height:32px;text-align:center"/>
					</div>
					
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">转出原因</label>
						<#code type="select" id="zdyy_select" name="_query.toShopReason" code="code_zdyy"  isSelectDef="false" class="easyui-combobox inputBox theme-textbox-radius" style="width:212px;height:32px;text-align:center;"  />
					</div>
					<div style="margin-bottom: 10px;float:left;margin-top: 16px;margin-right: 10px;">
						<a href="#" onclick='searchFrom()' class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:212px">搜索</a>
					</div>
				</form>
			</div>
			<div data-options="region:'center'" style="overflow-x:hidden;">
					<div class="easyui-layout">
					<div id="toShopStatistic_tabs" class="easyui-tabs" style="width:100%;height:325px;">
						<div title="顾客转入" style="padding:10px">
							<table id="intoShop_datagrid"  style="width: 100%; height: 100%;">
								<thead frozen="true">
									<tr>
										<th data-options="field:'date',width:80,align:'center'">时间</th>
										<th data-options="field:'cusids',width:80,align:'center',hidden:true">ids</th>
										<th data-options="field:'cusname',width:80,align:'center'">姓名</th>
										<!-- <th data-options="field:'cusphone',width:100,align:'center'">手机号码</th> -->
										<th data-options="field:'cushybh',width:100,align:'center'">顾客编号</th>
									</tr>
								</thead>
								<thead>
									<tr>
										<th data-options="field:'firstloseweighttime',width:150,align:'center'">首次减重时间</th>
										<th data-options="field:'lastloseweighttime',width:150,align:'center'">最后减重时间</th>
										<th data-options="field:'lastweight',width:100,align:'center'">最后体重</th>
										<th data-options="field:'delweightnum',width:100,align:'center'">减重次数</th>
										<th data-options="field:'outshop',width:150,align:'center'">转出门店</th>
										<th data-options="field:'outtime',width:150,align:'center'">转出时间</th>
										<th data-options="field:'isconfirm',width:80,align:'center'" formatter='isConfirm'>是否确认</th>
										<th data-options="field:'intotime',width:150,align:'center'">转入时间</th>
										<th data-options="field:'confirmuser',width:80,align:'center'">确认人员</th>
										<th data-options="field:'confirmtime',width:80,align:'center'">确认时间</th>
										<th data-options="field:'toshopreason',width:150,align:'center'">转店原因</th>
										<th data-options="field:'toshoprequisition',width:150,align:'center'" formatter='operation'>转店通知单</th>
									</tr>
								</thead>
							</table>
						</div>
						<div title="顾客转出" style="padding:10px">
							<table id="outShop_datagrid"  style="width: 100%; height: 100%;">
								<thead frozen="true">
									<tr>
										<th data-options="field:'date',width:80,align:'center'">时间</th>
										<th data-options="field:'cusids',width:80,align:'center',hidden:true">ids</th>
										<th data-options="field:'cusname',width:80,align:'center'">姓名</th>
										<!-- <th data-options="field:'cusphone',width:100,align:'center'">手机号码</th> -->
										<th data-options="field:'cushybh',width:100,align:'center'">顾客编号</th>
									</tr>
								</thead>
								<thead>
									<tr>
										<th data-options="field:'firstloseweighttime',width:150,align:'center'">首次减重时间</th>
										<th data-options="field:'lastloseweighttime',width:150,align:'center'">最后减重时间</th>
										<th data-options="field:'lastweight',width:100,align:'center'">最后体重</th>
										<th data-options="field:'delweightnum',width:100,align:'center'">减重次数</th>
										<th data-options="field:'outtime',width:150,align:'center'">转出时间</th>
										<th data-options="field:'intoshop',width:150,align:'center'">转入门店</th>
										<th data-options="field:'isconfirm',width:80,align:'center'">是否确认</th>
										<th data-options="field:'intotime',width:150,align:'center'">转入时间</th>
										<th data-options="field:'confirmuser',width:80,align:'center'">确认人员</th>
										<th data-options="field:'confirmtime',width:80,align:'center'">确认时间</th>
										<th data-options="field:'toshopreason',width:150,align:'center'">转店原因</th>
										<th data-options="field:'toshoprequisition',width:150,align:'center'" formatter='operation2'>转店通知单</th>
									</tr>
								</thead> 
							</table>
							<div id="intotb" style="height:34px;">
								<div style="margin-top: 3px;">
									<a href="#" onclick='customerInfo_xlsinto()' class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:67px">导出</a>
								</div>
							</div>
							<div id="outtb" style="height:34px;">
								<div style="margin-top: 3px;">
									<a href="#" onclick='customerInfo_xlsout()' class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:67px">导出</a>
								</div>
							</div>
						</div>
						
					</div>
				</div>
			</div>
			<div id="menuContent" class="menuContent" style="display: none; position: absolute;z-index: 10;">
				<ul id="organSelectTree" class="ztree" style="margin-top:0;width: 200px;"></ul>
			</div>
			<div id="intomenuContent" class="menuContent" style="display: none; position: absolute;z-index: 10;">
				<ul id="intoorganSelectTree" class="ztree" style="margin-top:0;width: 200px;"></ul>
			</div>
			<div id="outmenuContent" class="menuContent" style="display: none; position: absolute;z-index: 10;">
				<ul id="outorganSelectTree" class="ztree" style="margin-top:0;width: 200px;"></ul>
			</div>
			<script src="sb/js/statistic/toShopStatistic/toShopStatistic.js" type="text/javascript" charset="utf-8"></script>
			<script type="text/javascript">
				
				function  operation(value,row)
				{	
					var cusIds=row.cusids;
					return '<button href="#" style="height:25px;width:50px;background:#00A65A;color:white" onclick="lookRequisition(\'' + cusIds + '\')">查看</button>';
				}
				function  lookRequisition(cusIds)
				{
					loadDialog(null,null, '顾客转入单', '${cxt !}/bintoShop/showOutInfo?customerIds='+cusIds);
				}
				function  operation2(value,row)
				{	
					var cusIds=row.cusids;
					return '<button href="#" style="height:25px;width:50px;background:#00A65A;color:white" onclick="lookRequisition2(\'' + cusIds + '\')">查看</button>';
				}
				function  lookRequisition2(cusIds)
				{
					loadDialog(null,null, '顾客转出单', '${cxt !}/boutShop/showOutInfo?customerIds='+cusIds);
				}
				
				function  isConfirm(value,row)
				{	
					var isConfirm=row.isconfirm;
					if(isConfirm=='0'){
						return '否';
					}else if(isConfirm=='1'){
						return '是';
					}
					
				}
				
				function  customerInfo_xlsinto()
				{	
					var startTime=$('#startTime').val();
					var endTime=$('#endTime').val();
					var organIds=$('#organIds').val();
					var cushybh=$('#cushybh').val();
					var cusname=$('#cusname').val();
					var cusphone=$('#cusphone').val();
					var outorganIds=$('#outorganIds').val();
					var zdyy_select=$('#zdyy_select').combobox("getValue");
					var url = "${cxt!}/toShopStatistic/intoexcel?startTime=" + startTime + "&endTime=" + endTime+"&organIds="+organIds+
							"&outorganIds="+outorganIds+"&cushybh="+cushybh+"&cusname="+cusname+"&cusphone="+cusphone+"&zdyy_select="+zdyy_select;
					window.location.href = url;
					
				}
				function customerInfo_xlsout()
				{	
					var startTime=$('#startTime').val();
					var endTime=$('#endTime').val();
					var organIds=$('#organIds').val();
					var cushybh=$('#cushybh').val();
					var cusname=$('#cusname').val();
					var cusphone=$('#cusphone').val();
					var intoorganIds=$('#intoorganIds').val();
					var zdyy_select=$('#zdyy_select').combobox("getValue");
					var url = "${cxt!}/toShopStatistic/outexcel?startTime=" + startTime + "&endTime=" + endTime+"&organIds="+organIds+
					"&intoorganIds="+intoorganIds+"&cushybh="+cushybh+"&cusname="+cusname+"&cusphone="+cusphone+"&zdyy_select="+zdyy_select;
			window.location.href = url;
				}
			</script>
<!-- 		查询门店 -->
		<script type="text/javascript">
			var setting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClick,
					onAsyncSuccess : organTreeOnAsyncSuccess
				}
			};
			var flag=0;//只初始化一次标识
			function organTreeOnAsyncSuccess(event, treeId, msg) {
				if(flag == 0){
					flag = 1;
				}
			}
			function onClick(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("organSelectTree");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
						
					}
				}
				var cityObj = $("#organ");
				cityObj.attr("value", path);
				$("#organIds").attr("value", treeNode.id);
				hideMenu();
			}
			function showMenu() {
				var cityObj = $("#organ");
				var cityOffset = $("#organ").offset();
				$("#menuContent").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
		
				$("body").bind("mousedown", onBodyDown);
			}
			function hideMenu() {
				$("#menuContent").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDown);
			}
			function onBodyDown(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "menuContent" || $(event.target)
						.parents("#menuContent").length > 0)) {
					hideMenu();
				}
			}
			$.fn.zTree.init($("#organSelectTree"), setting);
		</script>
		
<!-- 		转入门店 -->
		<script type="text/javascript">
			var intoParentOrganIds=$('#parentOrganIds').val();
			var intosetting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getBeOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					otherParam : {
						"organIds" : intoParentOrganIds
					},
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : intoonClick,
					onAsyncSuccess : intoorganTreeOnAsyncSuccess
				}
			};
			var intoflag=0;//只初始化一次标识
			function intoorganTreeOnAsyncSuccess(event, treeId, msg) {
				if(intoflag == 0){
					var organTree = $.fn.zTree.getZTreeObj("intoorganSelectTree");
					var nodes = organTree.getNodes();
					intoflag = 1;
				}
			}
			function intoonClick(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("intoorganSelectTree");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
						
					}
				}
				var cityObj = $("#intoorgan");
				cityObj.attr("value", path);
				
				$("#intoorganIds").attr("value", treeNode.id);
				intohideMenu();
			}
			function intoshowMenu() {
				var cityObj = $("#intoorgan");
				var cityOffset = $("#intoorgan").offset();
				$("#intomenuContent").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
				$("body").bind("mousedown", intoonBodyDown);
			}
			function intohideMenu() {
				$("#intomenuContent").fadeOut("fast");
				$("body").unbind("mousedown", intoonBodyDown);
			}
			function intoonBodyDown(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "intomenuContent" || $(event.target)
						.parents("#intomenuContent").length > 0)) {
					intohideMenu();
				}
			}
			$.fn.zTree.init($("#intoorganSelectTree"), intosetting);
		</script>
<!-- 		转出门店 -->
		<script type="text/javascript">
			var outParentOrganIds=$('#parentOrganIds').val();
			var outsetting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getBeOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					otherParam : {
						"organIds" : outParentOrganIds
					},
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : outonClick,
					onAsyncSuccess : outorganTreeOnAsyncSuccess
				}
			};
			var outflag=0;//只初始化一次标识
			function outorganTreeOnAsyncSuccess(event, treeId, msg) {
				if(outflag == 0){
					var organTree = $.fn.zTree.getZTreeObj("outorganSelectTree");
					var nodes = organTree.getNodes();
					outflag = 1;
				}
			}
			function outonClick(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("outorganSelectTree");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
						
					}
				}
				var cityObj = $("#outorgan");
				cityObj.attr("value", path);
				$("#outorganIds").attr("value", treeNode.id);
				outhideMenu();
			}
			function outshowMenu() {
				var cityObj = $("#outorgan");
				var cityOffset = $("#outorgan").offset();
				$("#outmenuContent").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
				$("body").bind("mousedown", outonBodyDown);
			}
			function outhideMenu() {
				$("#outmenuContent").fadeOut("fast");
				$("body").unbind("mousedown", outonBodyDown);
			}
			function outonBodyDown(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "outmenuContent" || $(event.target)
						.parents("#outmenuContent").length > 0)) {
					outhideMenu();
				}
			}
			$.fn.zTree.init($("#outorganSelectTree"), outsetting);
		</script>
		<script type="text/javascript">
			
	//			var zdyy_select=$('#zdyy_select').combobox('getValue');
			
			
		
		</script>
	</body>
</html>
